package TUILayer;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.JScrollBar;

import ControlLayer.CustomerCtr;
import ControlLayer.DiscountCtr;
import ControlLayer.EmployeeCtr;
import ControlLayer.OrderCtr;
import ControlLayer.ProductCtr;
import ModelLayer.Customer;
import ModelLayer.CustomerList;
import ModelLayer.Discount;
import ModelLayer.DiscountList;
import ModelLayer.Employee;
import ModelLayer.EmployeeList;
import ModelLayer.Order;
import ModelLayer.OrderList;
import ModelLayer.Product;
import ModelLayer.ProductList;


import TUILayer.homeView.DropDownItem;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.Box;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTable;
import javax.swing.JList;

import java.awt.List;
import java.awt.Checkbox;
import java.awt.Font;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.Choice;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionEvent;

import javax.swing.JProgressBar;

import java.awt.SystemColor;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.FieldPosition;

import javax.swing.JPasswordField;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.JComboBox;

public class homeView extends JFrame {

	private static final String True = null;
	protected static final JLabel list = null;
	private JPanel contentPane;
	private static OrderList orderList;
	private static CustomerList customerList;
	private static OrderCtr orderCtr;
	private static ProductCtr productCtr;
	private static ProductList productList;
	private static EmployeeList employeeList;
	private static CustomerCtr customerCtr;
	private static DiscountList discountList;
	private static DiscountCtr discountCtr;
	private static EmployeeCtr employeeCtr;
	private JTextField orderId_text;
	private JTextField textField_2;
	private JTextField txtfield;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
	private JTextField textField_8;
	private JTextField textField_9;
	private JTextField textField_10;
	private JTextField textField_11;
	private JTextField textField_12;
	private JTextField textFieldCustomerDiscount;
	private JTextField textDiscountId;
	private JTextField textDiscountName;
	private JTextField textDiscountFrom;
	private JTextField textDiscountTo;
	private JTextField textDiscountAmount;
	private JTextField textProductId;
	private JTextField textProductName;
	private JTextField textProductAmount;
	private JTextField textProductPrice;
	private DefaultListModel<String> model;
	private DefaultListModel<String> model_customer;
	private DefaultListModel<String> model_customer_1;
	private DefaultListModel<String> model_discount;
	private DefaultListModel<String> model_discount_1;
	private DefaultListModel<String> modelProduct;
	private DefaultListModel<String> modelProductData;
	private DefaultListModel<String> modelUserId;
	private DefaultListModel<String> modelUserData;
	private DefaultListModel<String> modelOrderProductId;
	private DefaultListModel<String> modelOrderProductData;
	private JTextField textPostal;
	private JTextField textPhone;
	private JTextField textNotification;
	private JTextField textFieldUserId;
	private JTextField textFieldUserName;
	private JTextField textFieldUserSurname;
	private JTextField textFieldUserEmail;
	private JTextField textUserRole;
	private JTextField textFieldUserPhone;
	private JPasswordField passwordField;
	private Customer customerName;
	private  final JList<String> customerList_view;
	private  final JList<String> discountView_id;
	private  final JList<String> productView_id;
	private  final JList<String> listUserId;
	private  final JList<String> listProductId;
	private JTextField textNotification1;
	private Discount[] discounts;
	private JTextField productDiscountId;
	private JTextField textFieldOrderDiscount;
	private JTextField textFieldOrderCustomerName;
	private JTextField orderProductName;
	private JTextField orderProductAmount;
	
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					orderList = OrderList.getInstance();
					orderList.addOrder(new Order(1,"test","test"));
					customerList = CustomerList.getInstance();
					discountList = DiscountList.getInstance();
					productList = ProductList.getInstance();
					employeeList = EmployeeList.getInstance();
					customerCtr = new CustomerCtr();
					orderCtr = new OrderCtr();
					discountCtr = new DiscountCtr();
					productCtr = new ProductCtr();
					employeeCtr = new EmployeeCtr();
					homeView frame = new homeView();
					frame.setVisible(true);
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			
			
			
			
		});
	}

	/**
	 * Create the frame.
	 */
	
	
	
	
	public homeView() {
		setResizable(false);
		setTitle("Logitech");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 806, 560);
		contentPane = new JPanel();
		contentPane.setBackground(SystemColor.activeCaption);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textNotification = new JTextField();
		textNotification.setText("SYSTEM: Loading GUI: OK... Loading Data: OK... Done.");
		textNotification.setEditable(false);
		textNotification.setForeground(Color.RED);
		textNotification.setBounds(198, 486, 481, 20);
		contentPane.add(textNotification);
		textNotification.setColumns(10);
		
		
  	    
  	   // String test1 = Long.toString(test);
  	    //String orderIdtext = Long.toString(orderId);
  	    
  	    final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
  	    tabbedPane.setBounds(198, 43, 582, 432);
  	    contentPane.add(tabbedPane);
  	    
  	    JPanel panel_1 = new JPanel();
  	    panel_1.setBackground(SystemColor.inactiveCaption);
  	    tabbedPane.addTab("Order View", null, panel_1, null);
  	    panel_1.setLayout(null);
  	    
  	    
  	    JLabel lblOrderId = new JLabel("Order ID:");
  	    lblOrderId.setBounds(10, 11, 73, 14);
  	    panel_1.add(lblOrderId);
  	    
  	    orderId_text = new JTextField();
  	    orderId_text.setBounds(93, 8, 86, 20);
  	    panel_1.add(orderId_text);
  	    orderId_text.setColumns(10);
  	    
  	    JLabel lblRegistrationDate = new JLabel("Booking date:");
  	    lblRegistrationDate.setBounds(10, 42, 101, 14);
  	    panel_1.add(lblRegistrationDate);
  	    
  	    textField_2 = new JTextField();
  	    textField_2.setBounds(93, 39, 86, 20);
  	    //textField_2.setText(orderCtr.getOrderDate(orderId));
  	    panel_1.add(textField_2);
  	    textField_2.setColumns(10);
  	    
  	    JLabel lblDeliveryDate = new JLabel("Delivery date:");
  	    lblDeliveryDate.setBounds(10, 73, 86, 14);
  	    panel_1.add(lblDeliveryDate);
  	    
  	    txtfield = new JTextField();
  	    txtfield.setBounds(93, 67, 86, 20);
  	    //txtfield.setText(orderCtr.getDelDate(orderId));
  	    panel_1.add(txtfield);
  	    txtfield.setColumns(10);
  	    
  	    JLabel lblOrderStatus = new JLabel("Order status:");
  	    lblOrderStatus.setBounds(189, 11, 96, 14);
  	    panel_1.add(lblOrderStatus);
  	    
  	    textField_4 = new JTextField();
  	    textField_4.setEditable(false);
  	    //textField_4.setText(orderCtr.findOrder(orderId).getStatus());
  	    textField_4.setBounds(295, 8, 130, 20);
  	    panel_1.add(textField_4);
  	    textField_4.setColumns(10);
  	    
  	    JButton btnSave = new JButton("Create");
  	    btnSave.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent arg0) 
  	    	{
  	    		long orderId = Long.valueOf(orderId_text.getText());
  	    		String bookingDate = textField_2.getText();
  	    		String delDate = txtfield.getText();
  	    		textField_4.setText("Processing");
  	    		//int customerId = Integer.valueOf(textFieldOrderCustomer.getText());
  	    		String name = textFieldOrderCustomerName.getText();
  	    		int customerId = customerCtr.getCustomerIdByName(name);
  	    		
  	    		//Order order = new Order(orderId,bookingDate,delDate,customerId);
  	    		orderCtr.createOrder(orderId, bookingDate, delDate, customerId);
  	    		//orderList.addOrder(order);
  	    		model.addElement(Long.toString(orderId));
  	    		textField_5.setText(customerCtr.getPhoneNumber(customerId));
  	    		//customerName = customerList.findCustomer(customerId); 	
  	    		 	
  	    		//String name = customerName.getCompanyName();
  	    		//textFieldOrderCustomerName.setText(name);
  	    		//model_orders_1.addElement(customerList.findCustomer(customerId));
  	    		textNotification.setText("SYSTEM: Order with OrderID" +" "+ orderId+" " + "was created.");
  	    		//orderList.addOrder(order);
  	    		
  	    	}
  	    });
  	    btnSave.setBounds(490, 7, 77, 23);
  	    panel_1.add(btnSave);
  	    
  	    JButton btnNew = new JButton("Edit");
  	    btnNew.setBounds(490, 38, 77, 23);
  	    panel_1.add(btnNew);
  	    
  	    JLabel lblCustomer = new JLabel("Customer:");
  	    lblCustomer.setBounds(189, 42, 65, 14);
  	    panel_1.add(lblCustomer);
  	    
  	    JLabel lblDiscount = new JLabel("Contact:");
  	    lblDiscount.setBounds(189, 70, 96, 14);
  	    panel_1.add(lblDiscount);
  	    
  	    textField_5 = new JTextField();
  	    textField_5.setEditable(false);
  	    textField_5.setBounds(295, 70, 130, 20);
  	    panel_1.add(textField_5);
  	    textField_5.setColumns(10);
  	    
  	    JLabel lblOrderGoods = new JLabel("Order Goods:");
  	    lblOrderGoods.setFont(new Font("Tahoma", Font.BOLD, 11));
  	    lblOrderGoods.setBounds(10, 133, 86, 14);
  	    panel_1.add(lblOrderGoods);
  	    
  	    JLabel label = new JLabel("_______________________________________________________________________________");
  	    label.setBounds(10, 144, 557, 14);
  	    panel_1.add(label);
  	    
  	    JLabel lblInvoice = new JLabel("Invoice:");
  	    lblInvoice.setFont(new Font("Tahoma", Font.BOLD, 11));
  	    lblInvoice.setBounds(10, 302, 46, 14);
  	    panel_1.add(lblInvoice);
  	    
  	    JLabel label_1 = new JLabel("_______________________________________________________________________________");
  	    label_1.setBounds(10, 314, 557, 14);
  	    panel_1.add(label_1);
  	    
  	    JLabel lblAmount = new JLabel("Amount:");
  	    lblAmount.setBounds(10, 339, 65, 14);
  	    panel_1.add(lblAmount);
  	    
  	    textField_6 = new JTextField();
  	    textField_6.setEditable(false);
  	    textField_6.setBounds(68, 336, 86, 20);
  	    panel_1.add(textField_6);
  	    textField_6.setColumns(10);
  	    
  	    JButton btnCalculate = new JButton("Calculate");
  	    btnCalculate.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long orderId = Long.valueOf(orderId_text.getText());
  	    		String amount = String.valueOf(orderCtr.getInvoiceAmount(orderId));
  	    		textField_6.setText(amount);
  	    	}
  	    });
  	    btnCalculate.setBounds(65, 363, 89, 23);
  	    panel_1.add(btnCalculate);
  	    
  	    JButton btnAddProduct = new JButton("+");
  	    btnAddProduct.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		String productName = textFieldOrderCustomerName.getText();
  	    		int productId = productCtr.getProductIdByName(productName);
  	    		int quantity = Integer.valueOf(orderProductAmount.getText());
  	    		long orderId = Integer.valueOf(orderId_text.getText());
  	    		String name = productCtr.getProductName(productId);
  	    		
  	    		orderCtr.addProduct(quantity, orderId, productId);
  	    		modelOrderProductId.addElement(Integer.toString(productId));
  	    		modelOrderProductData.addElement(name+"/"+quantity);
  	    		textNotification.setText("SYSTEM: Product were added to the order.");
  	    	}
  	    });
  	    btnAddProduct.setToolTipText("Add");
  	    btnAddProduct.setBounds(473, 298, 46, 23);
  	    panel_1.add(btnAddProduct);
  	    
  	    JButton btnDelete = new JButton("Delete");
  	    btnDelete.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long orderId = Long.valueOf(orderId_text.getText());
  	    		orderCtr.deleteOrder(orderId);
  	    		textNotification.setText("SYSTEM: Order" +" "+ orderId+" " + "was deleted.");	
  	    	}
  	    });
  	    btnDelete.setBounds(490, 69, 77, 23);
  	    panel_1.add(btnDelete);
  	    
  	    JButton btnGenerate = new JButton("Order Note");
  	    btnGenerate.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		Long orderId = Long	.valueOf(orderId_text.getText());
  	    		String name = textFieldOrderCustomerName.getText();
  	    		String amount = String.valueOf(orderCtr.getInvoiceAmount(orderId));
  	    		//File file = new File("C:\\Users\\artur_000\\Google Drive\\Eclipse\\Logitch\\Invoice_"+orderId+"_"+name+".txt");
  	    		BufferedWriter writer = null;
  	    		
  	    	  
  	    	    
  	    	 try {
  	    	writer = new BufferedWriter(new FileWriter("C:\\Users\\artur_000\\Google Drive\\Eclipse\\Logitch\\OrderNote_"+orderId+"_"+name+".txt",true));
				    
  	    	
  	    			writer.write("******************************************");
  	    			writer.newLine();
  	    	        writer.write("Vestbjerg Byggecenter A/S Customer OrderNote");
  	    	        writer.newLine();
  	    	        writer.write("******************************************");
  	    	        writer.newLine();
  	    	        writer.write("Customer"+name+"has payd for order"+orderId);
  	    	        writer.newLine();
  	    	        writer.write("Please check Status in the system.");
  	    	        writer.write("Vestbjerg Byggecenter A/S Finance Department.");
  	    	        textNotification.setText("SYSTEM: OrderNote for customer " +name+ " was created.");
  	    	        
  	    	        
  	    	        
  	    	        
  	    	        
  	    	        writer.close();
  	    	        
  	    	  	} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
  	    	  
  	    	}
  	    	
  	    });
  	    btnGenerate.setBounds(458, 363, 109, 23);
  	    panel_1.add(btnGenerate);
  	    
  	    JLabel lblDiscount_3 = new JLabel("Discount:");
  	    lblDiscount_3.setBounds(10, 101, 73, 14);
  	    panel_1.add(lblDiscount_3);
  	    
  	    textFieldOrderDiscount = new JTextField();
  	    textFieldOrderDiscount.setBounds(93, 98, 86, 20);
  	    panel_1.add(textFieldOrderDiscount);
  	    textFieldOrderDiscount.setColumns(10);
  	    
  	    textFieldOrderCustomerName = new JTextField();
  	    textFieldOrderCustomerName.setBounds(295, 39, 130, 20);
  	    panel_1.add(textFieldOrderCustomerName);
  	    textFieldOrderCustomerName.setColumns(10);
  	    
  	    JButton button_1 = new JButton("+");
  	    button_1.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long orderId = Long.valueOf(orderId_text.getText());
  	    		String discountName = textFieldOrderDiscount.getText();
  	    		Long discountId = discountCtr.getDiscountIdByName(discountName);
  	    		
  	    		orderCtr.addDiscount(discountId, orderId);
  	    	}
  	    });
  	    button_1.setToolTipText("Add");
  	    button_1.setBounds(189, 97, 41, 23);
  	    panel_1.add(button_1);
  	    
  	    JLabel lblName_4 = new JLabel("Name:");
  	    lblName_4.setBounds(189, 302, 46, 14);
  	    panel_1.add(lblName_4);
  	    
  	    orderProductName = new JTextField();
  	    orderProductName.setBounds(229, 299, 86, 20);
  	    panel_1.add(orderProductName);
  	    orderProductName.setColumns(10);
  	    
  	    JLabel lblAmount_2 = new JLabel("Amount:");
  	    lblAmount_2.setBounds(321, 302, 56, 14);
  	    panel_1.add(lblAmount_2);
  	    
  	    orderProductAmount = new JTextField();
  	    orderProductAmount.setBounds(376, 299, 86, 20);
  	    panel_1.add(orderProductAmount);
  	    orderProductAmount.setColumns(10);
  	    
  	    listProductId = new JList<String>();
  	    listProductId.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    listProductId.setBounds(10, 170, 46, 121);
  	    panel_1.add(listProductId);
  	    modelOrderProductId = new DefaultListModel<String>();
	    for(int i = 0; i > productList.size(); i++)
	    {
	    	Product product = productList.products.get(i);
	    	String temp = (Integer.toString(product.getId()));    	
	    	model_customer.addElement(temp);  		    	
	    }
	    
	    listProductId.setModel(modelOrderProductId);
  	    
  	    JLabel lblId_4 = new JLabel("ID");
  	    lblId_4.setBounds(10, 158, 46, 14);
  	    panel_1.add(lblId_4);
  	    
  	    JList<String> ListProductData = new JList<String>();
  	    ListProductData.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    ListProductData.setBounds(55, 170, 512, 121);
  	    panel_1.add(ListProductData);
  	    modelOrderProductData = new DefaultListModel<String>();
	    for(int i = 0; i > productList.size(); i++)
	    {
	    	Product product = productList.products.get(i);
	    	String temp = (Integer.toString(product.getId()));    	
	    	modelProductData.addElement(temp);  		    	
	    }
	    
	    ListProductData.setModel(modelOrderProductData);     
  	    
  	    JLabel lblNameamount = new JLabel("Name/Amount");
  	    lblNameamount.setBounds(55, 158, 124, 14);
  	    panel_1.add(lblNameamount);
  	    
  	    JButton btnNewButton = new JButton("-");
  	    btnNewButton.setToolTipText("Remove");
  	    btnNewButton.setBounds(521, 298, 46, 23);
  	    panel_1.add(btnNewButton);
  	    
  	    JButton btnInvoice = new JButton("Invoice");
  	    btnInvoice.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		
  	    		Long orderId = Long	.valueOf(orderId_text.getText());
  	    		String name = textFieldOrderCustomerName.getText();
  	    		String amount = String.valueOf(orderCtr.getInvoiceAmount(orderId));
  	    		//File file = new File("C:\\Users\\artur_000\\Google Drive\\Eclipse\\Logitch\\Invoice_"+orderId+"_"+name+".txt");
  	    		BufferedWriter writer = null;
  	    		
  	    	  
  	    	    
  	    	 try {
  	    	writer = new BufferedWriter(new FileWriter("C:\\Users\\artur_000\\Google Drive\\Eclipse\\Logitch\\Invoice_"+orderId+"_"+name+".txt",true));
				    
  	    	
  	    			writer.write("******************************************");
  	    			writer.newLine();
  	    	        writer.write("Vestbjerg Byggecenter A/S Customer E-Invoice");
  	    	        writer.newLine();
  	    	        writer.write("******************************************");
  	    	        writer.newLine();
  	    	        writer.write("Hello"+name+"!");
  	    	        writer.newLine();
  	    	        writer.newLine();
  	    	        writer.write("You recived this E-Invoice because of Your order:"+orderId);
  	    	        writer.newLine();
  	    	        writer.write("******************************************");
  	    	      writer.newLine();
  	    	        writer.write("If You have any questions you can contact our customer support:");
  	    	      writer.newLine();
  	    	        writer.write("Phone number: +45 909 000 000- Mon-Friday - 09.00-17.00"); 
  	    	      writer.newLine();
  	    	        writer.write("Mobile number: +45 909 232 232- Mon-Friday - 09.00-20.00" );
  	    	      writer.newLine();
  	    	        writer.write("******************************************");
  	    	        writer.newLine();
  	    	        writer.write("Total invoice amount is:"+ amount+"DDK.");
  	    	      writer.newLine();
  	    	        writer.write("You can pay E-Invoice by net bank.");
  	    	        writer.newLine();
  	    	        writer.write("******************************************");
  	    	      writer.newLine();
  	    	        writer.write("Bank account: 9309234093");
  	    	      writer.newLine();
  	    	        writer.write("Reciver: Vestbjerg Byggecenter A/S ");
  	    	      writer.newLine();
  	    	        writer.write("******************************************");
  	    	        writer.newLine();
  	    	        writer.write("This E-Invoice should be payd no longer than 7 days,after reciving invoice.");
  	    	        writer.newLine();
  	    	        writer.newLine();
  	    	        writer.write("Vestbjerg Byggecenter A/S Finance Department.");
  	    	        textNotification.setText("SYSTEM: Invoice for customer " +name+ " was created.");
  	    	        
  	    	        
  	    	        
  	    	        
  	    	        
  	    	        writer.close();
  	    	        
  	    	  	} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
  	    	   
  	    	}
  	    	
  	    });
  	    btnInvoice.setBounds(458, 335, 109, 23);
  	    panel_1.add(btnInvoice);
  	    
  	    final JPanel panel_2 = new JPanel();
  	    panel_2.setBackground(SystemColor.inactiveCaption);
  	    tabbedPane.addTab("Customer View", null, panel_2, null);
  	  
  	    panel_2.setLayout(null);
  	   
  	    
  	    JLabel lblNewLabel = new JLabel("Customer ID:");
  	    lblNewLabel.setBounds(10, 11, 83, 14);
  	    panel_2.add(lblNewLabel);
  	    
  	    JLabel lblName = new JLabel("Name:");
  	    lblName.setBounds(10, 36, 46, 14);
  	    panel_2.add(lblName);
  	    
  	    JLabel lblSurname = new JLabel("City:");
  	    lblSurname.setBounds(10, 61, 66, 14);
  	    panel_2.add(lblSurname);
  	    
  	    JLabel lblAddress = new JLabel("Address:");
  	    lblAddress.setBounds(10, 86, 83, 14);
  	    panel_2.add(lblAddress);
  	    
  	    textField_7 = new JTextField();
  	    textField_7.setBounds(86, 8, 86, 20);
  	    panel_2.add(textField_7);
  	    textField_7.setColumns(10);
  	    
  	    textField_8 = new JTextField();
  	    textField_8.setBounds(86, 33, 86, 20);
  	    panel_2.add(textField_8);
  	    textField_8.setColumns(10);
  	    
  	    textField_9 = new JTextField();
  	    textField_9.setBounds(86, 58, 86, 20);
  	    panel_2.add(textField_9);
  	    textField_9.setColumns(10);
  	    
  	    textField_10 = new JTextField();
  	    textField_10.setBounds(86, 83, 295, 20);
  	    panel_2.add(textField_10);
  	    textField_10.setColumns(10);
  	    
  	    JLabel lblEmail = new JLabel("Email:");
  	    lblEmail.setBounds(182, 36, 46, 14);
  	    panel_2.add(lblEmail);
  	    
  	    JLabel lblDiscount_1 = new JLabel("Discount:");
  	    lblDiscount_1.setBounds(182, 61, 66, 14);
  	    panel_2.add(lblDiscount_1);
  	    
  	    JLabel lblCompany = new JLabel("Company:");
  	    lblCompany.setBounds(182, 11, 75, 14);
  	    panel_2.add(lblCompany);
  	    
  	    textField_11 = new JTextField();
  	    textField_11.setBounds(258, 8, 123, 20);
  	    panel_2.add(textField_11);
  	    textField_11.setColumns(10);
  	    
  	    textField_12 = new JTextField();
  	    textField_12.setBounds(258, 33, 123, 20);
  	    panel_2.add(textField_12);
  	    textField_12.setColumns(10);
  	    
  	    textFieldCustomerDiscount = new JTextField();
  	    textFieldCustomerDiscount.setBounds(258, 58, 33, 20);
  	    panel_2.add(textFieldCustomerDiscount);
  	    textFieldCustomerDiscount.setColumns(10);
  	    
  	    JButton btnSave_1 = new JButton("Create");
  	    btnSave_1.setToolTipText("Create new customer");
  	    btnSave_1.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent agr0) 
  	    	{  		
  	    		int customerId = Integer.valueOf(textField_7.getText());
  	    		
  	    			
  	    		String name = textField_8.getText();
  	    		String company = textField_11.getText();
  	    		String city = textField_9.getText();
  	    		String address = textField_10.getText();
  	    		String postalCode = textPostal.getText();
  	    		String phoneNumber = textPhone.getText();
  	    		String email = textField_12.getText(); 
  	    		
  	    		customerCtr.createCustomer(customerId, name, company, city, address, postalCode, phoneNumber, email);
  	    		model_customer.addElement(Integer.toString(customerId));
  	    		model_customer_1.addElement(name+"/"+ company+"/"+ address);
  	    		textNotification.setText("SYSTEM: Customer:"+" "+name+" "+"with customer ID"+" "+customerId+" "+"was created.");
  	    		
  	    	}
  	    });
  	    btnSave_1.setBounds(478, 7, 89, 23);
  	    panel_2.add(btnSave_1);
  	    
  	    JButton btnNew_1 = new JButton("Edit");
  	    btnNew_1.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e)
  	    	{
  	    		//UPDATE HERE
  	    	}
  	    });
  	    btnNew_1.setBounds(478, 32, 89, 23);
  	    panel_2.add(btnNew_1);
  	    
  	    JButton btnDelete_1 = new JButton("Delete");
  	    btnDelete_1.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		Integer customerId = Integer.valueOf(customerList_view.getSelectedValue());
  	    		customerCtr.deleteCustomer(customerId);
  	    		String name = textField_8.getText();
  	    		textNotification.setText("Customer:"+" "+name+" "+"with customer ID" + customerId + " " + "was deleted");
  	    		textField_7.setText(null);
  	    	    textField_8.setText(null);
  	    		textField_11.setText(null);
  	    		textField_9.setText(null);
  	    		textField_10.setText(null);
  	    		textPostal.setText(null);
  	    		textPhone.setText(null);
  	    		textField_12.setText(null);
  	    		textFieldCustomerDiscount.setText(null);
  	    		int selectedIndex = customerList_view.getSelectedIndex();
  	    		if (selectedIndex != -1) {
  	    		    model_customer.remove(selectedIndex);
  	    		    model_customer_1.remove(selectedIndex);
  	    		}
  	    		
  	    	}
  	    });
  	    btnDelete_1.setBounds(478, 57, 89, 23);
  	    panel_2.add(btnDelete_1);
  	    
  	    JLabel lblCustomerList = new JLabel("Customer list:");
  	    lblCustomerList.setBounds(10, 148, 97, 14);
  	    panel_2.add(lblCustomerList);
  	    
  	    JLabel lblPostalCode = new JLabel("Postal code:");
  	    lblPostalCode.setBounds(10, 117, 83, 14);
  	    panel_2.add(lblPostalCode);
  	    
  	    textPostal = new JTextField();
  	    textPostal.setBounds(86, 114, 86, 20);
  	    panel_2.add(textPostal);
  	    textPostal.setColumns(10);
  	    
  	    JLabel lblPhone = new JLabel("Phone:");
  	    lblPhone.setBounds(182, 114, 66, 14);
  	    panel_2.add(lblPhone);
  	    
  	    textPhone = new JTextField();
  	    textPhone.setBounds(237, 114, 144, 20);
  	    panel_2.add(textPhone);
  	    textPhone.setColumns(10);
  	    
  	    JLabel label_2 = new JLabel("_______________________________________________________________________________");
  	    label_2.setBounds(10, 159, 557, 14);
  	    panel_2.add(label_2);
  	    
  	    customerList_view = new JList<String>();
  	    customerList_view.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    customerList_view.addListSelectionListener(new ListSelectionListener() {
  	    	public void valueChanged(ListSelectionEvent e) 
  	    	{
  	    		if (!e.getValueIsAdjusting())
    		    {    
  	    			String str =  customerList_view.getSelectedValue();
                 if (str != null || str != "")
                 {
                	 Customer customer;
                 try{
                 customer = customerList.findCustomer(Integer.valueOf(str));
                 textField_8.setText(customer.getCustomerName());
   	    		 textField_11.setText(customer.getCompanyName());
   	    		 textField_9.setText(customer.getCity());
   	    		 textField_10.setText(customer.getAddress());
   	    		 textPostal.setText(customer.getPostalCode());
   	    		 textPhone.setText(customer.getPhoneNumber());
   	    		 textField_12.setText(customer.getEmail());
   	    		 textField_7.setText( customerList_view.getSelectedValue());
   	    		 
   	    		
                 }catch(Exception ex ){textNotification1.setText(ex.getMessage());}
                 
                 
    		    }
    		  }  
  	    	}
  	    });

  	    customerList_view.setBounds(10, 195, 64, 198);
  	    panel_2.add(customerList_view);
  	    
  	    model_customer = new DefaultListModel<String>();
	    for(int i = 0; i > customerList.size(); i++)
	    {
	    	Customer customer = customerList.customers.get(i);
	    	String temp = (Integer.toString(customer.getCustomerId()));    	
	    	model_customer.addElement(temp);  		    	
	    }
	    
	    customerList_view.setModel(model_customer);
	    
	    JList<String> customerList_data = new JList<String>();
	    customerList_data.setBorder(new LineBorder(new Color(0, 0, 0)));
	    customerList_data.setBounds(70, 195, 497, 198);
	    panel_2.add(customerList_data);
	    
	    model_customer_1 = new DefaultListModel<String>();
	    for(int i = 0; i > customerList.size(); i++)
	    {
	    	Customer customer = customerList.customers.get(i);
	    	String temp = (Integer.toString(customer.getCustomerId()));    	
	    	model_customer_1.addElement(temp);  		    	
	    }
	    customerList_data.setModel(model_customer_1);
	    
	    JLabel lblId = new JLabel("ID");
	    lblId.setBounds(10, 181, 46, 14);
	    panel_2.add(lblId);
	    
	    JLabel lblNamecompanyaddress = new JLabel("Name/Company/Address");
	    lblNamecompanyaddress.setBounds(76, 181, 507, 14);
	    panel_2.add(lblNamecompanyaddress);
	    
	    JButton btnAdd_1 = new JButton("+");
	    btnAdd_1.setToolTipText("Add");
	    btnAdd_1.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent arg0) 
	    	{
	    		Integer customerId = Integer.valueOf(textField_7.getText());
	    		Integer customerDiscount = Integer.valueOf(textFieldCustomerDiscount.getText());
	    		if(customerDiscount <= 10)
	    		{
	    			
	    			customerCtr.addCustomerDiscount(customerId, customerDiscount);
	    			textNotification.setText("SYSTEM: Added "+customerDiscount+"% customer discount.");
	    		}
	    		else
	    		{
	    			textNotification.setText("SYSTEM: Customer discount can't be bigger than 10!");
	    			textFieldCustomerDiscount.setText(null);
	    		}
	    		
	    	}
	    });
	    btnAdd_1.setBounds(296, 57, 41, 23);
	    panel_2.add(btnAdd_1);
	    
	    JButton button = new JButton("-");
	    button.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent e) 
	    	{
	    		Integer customerId = Integer.valueOf(textField_7.getText());
	    		try{
	    		if( Integer.valueOf(textFieldCustomerDiscount.getText()) != null)
	    		{
	    		customerCtr.removeCustoemrDiscount(customerId);
	    		textNotification.setText("SYSTEM: Customer discount was removed.");
	    		textFieldCustomerDiscount.setText(null);
	    		
	    		}
	    		else
	    		{
	    		textNotification.setText("SYSTEM: There is no discount!");
	    		}
	    		}catch(Exception ex ){textNotification1.setText(ex.getMessage());}
	    	}
	    });
	    button.setToolTipText("Remove");
	    button.setBounds(340, 57, 41, 23);
	    panel_2.add(button);
  	    
  	    final JPanel panel_3 = new JPanel();
  	    panel_3.setBackground(SystemColor.inactiveCaption);
  	    tabbedPane.addTab("Discount View", null, panel_3, null);
  	    panel_3.setLayout(null);
  	    
  	    
  	    JLabel lblDiscountId = new JLabel("Discount ID:");
  	    lblDiscountId.setBounds(10, 11, 69, 14);
  	    panel_3.add(lblDiscountId);
  	    
  	    JLabel lblName_1 = new JLabel("Name:");
  	    lblName_1.setBounds(10, 36, 46, 14);
  	    panel_3.add(lblName_1);
  	    
  	    textDiscountId = new JTextField();
  	    textDiscountId.setBounds(85, 8, 86, 20);
  	    panel_3.add(textDiscountId);
  	    textDiscountId.setColumns(10);
  	    
  	    textDiscountName = new JTextField();
  	    textDiscountName.setBounds(85, 33, 86, 20);
  	    panel_3.add(textDiscountName);
  	    textDiscountName.setColumns(10);
  	    
  	    JButton btnDiscountCreate = new JButton("Create");
  	    btnDiscountCreate.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long discountId = Long.valueOf(textDiscountId.getText());
  	    		int discountAmount = Integer.valueOf(textDiscountAmount.getText());
  	  	    	
  	    		String discountName = textDiscountName.getText();
  	    		String dateFrom = textDiscountFrom.getText();
  	    		String dateTill = textDiscountTo.getText();
  	    		

  	    		discountCtr.createDiscount(discountId, discountName, dateFrom, dateTill, discountAmount);
  	    		model_discount.addElement(Long.toString(discountId));
  	    		model_discount_1.addElement(discountName+"/"+discountAmount+" "+dateFrom+" "+dateTill);
  	    		textNotification.setText("SYSTEM: Discount:"+" "+discountName+" "+"with discount ID" + discountId + " " + "was craeted");
  	    		
  	    	}
  	    });
  	    btnDiscountCreate.setBounds(478, 7, 89, 23);
  	    panel_3.add(btnDiscountCreate);
  	    
  	    JButton btnNew_2 = new JButton("Edit");
  	    btnNew_2.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long discountId = Long.valueOf(textDiscountId.getText());
  	    		discountCtr.setDscountName(textDiscountName.getText(), discountId);
  	    		discountCtr.setDiscountAmount(Integer.valueOf(textDiscountAmount.getText()), discountId);
  	    		discountCtr.setDateTill(textDiscountTo.getText(), discountId);
  	    		discountCtr.setDateFrom(textDiscountFrom.getText(), discountId);	
  	    		textNotification.setText("SYSTEM: Discount:"+" "+"with discount ID" + discountId + " " + "was updated.");
  	    	}
  	    		
  	    	
  	    });
  	    btnNew_2.setBounds(478, 32, 89, 23);
  	    panel_3.add(btnNew_2);
  	    
  	    JLabel lblDateFrom = new JLabel("Date from:");
  	    lblDateFrom.setBounds(198, 11, 86, 14);
  	    panel_3.add(lblDateFrom);
  	    
  	    textDiscountFrom = new JTextField();
  	    textDiscountFrom.setBounds(272, 8, 86, 20);
  	    panel_3.add(textDiscountFrom);
  	    textDiscountFrom.setColumns(10);
  	    
  	    JLabel lblDateTo = new JLabel("Date to:");
  	    lblDateTo.setBounds(198, 36, 69, 14);
  	    panel_3.add(lblDateTo);
  	    
  	    textDiscountTo = new JTextField();
  	    textDiscountTo.setBounds(272, 33, 86, 20);
  	    panel_3.add(textDiscountTo);
  	    textDiscountTo.setColumns(10);
  	    
  	    JLabel lblAmount_1 = new JLabel("Amount:");
  	    lblAmount_1.setBounds(10, 61, 69, 14);
  	    panel_3.add(lblAmount_1);
  	    
  	    textDiscountAmount = new JTextField();
  	    textDiscountAmount.setBounds(85, 58, 86, 20);
  	    panel_3.add(textDiscountAmount);
  	    textDiscountAmount.setColumns(10);
  	    
  	    final JButton btnDelete_2 = new JButton("Delete");
  	    btnDelete_2.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e)
  	    	{
  	    		
  	    		long discountId = Long.valueOf(textDiscountId.getText());
  	    		discountCtr.deleteDiscount(discountId);
  	    		String discountName = textDiscountName.getText();
  	    		
  	    		
  	    	
  	    		textDiscountId.setText(null);
  	    		textDiscountFrom.setText(null);
  	    		textDiscountAmount.setText(null);
  	    		textDiscountName.setText(null);
  	    		textDiscountTo.setText(null);
  	    		int selectedIndex = discountView_id.getSelectedIndex();
  	    		if (selectedIndex != -1) {
  	    		    model_discount.remove(selectedIndex);
  	    		    model_discount_1.remove(selectedIndex);
  	    		  textNotification.setText("SYSTEM: Discount:"+" "+discountName+" "+"with discount ID" + discountId + " " + "was deleted.");
  	    		}
  	    		
  	    	}
  	    });
  	    btnDelete_2.setBounds(478, 57, 89, 23);
  	    panel_3.add(btnDelete_2);
  	    
  	    JLabel lblDiscuntList = new JLabel("Discount list:");
  	    lblDiscuntList.setBounds(10, 86, 80, 14);
  	    panel_3.add(lblDiscuntList);
  	    
  	    JLabel label_3 = new JLabel("_______________________________________________________________________________");
  	    label_3.setBounds(10, 101, 557, 14);
  	    panel_3.add(label_3);
  	    
  	    JLabel lblId_1 = new JLabel("ID");
  	    lblId_1.setBounds(10, 126, 46, 14);
  	    panel_3.add(lblId_1);
  	    
  	    discountView_id = new JList<String>();
  	    discountView_id.addListSelectionListener(new ListSelectionListener() {
  	    	public void valueChanged(ListSelectionEvent e) 
  	    	{
  	    		if (!e.getValueIsAdjusting())
    		    {    
    			  	
                   String str =  discountView_id.getSelectedValue();
                   if (str != null || str != "")
                   {
                	   Discount discount;
                	   try{
                   discount = discountList.findDiscount(Long.valueOf(str));
                   String amount = Integer.toString(discount.getDiscountAmount());
                   String discountIdText = Long.toString(discount.getDiscountId());
                   textDiscountId.setText(discountIdText);
                   textDiscountAmount.setText(amount);
                   textDiscountFrom.setText(discount.getDiscountDateFrom());
                   textDiscountTo.setText(discount.getDiscountDateTill());
                   textDiscountName.setText(discount.getDiscountName());
                   
                   
                   
                	   }catch(Exception ex ){textNotification1.setText(ex.getMessage());}
                	   
                	   
                	   
                  
                   
                   }
                   
                   
                }
  	    	}
  	    	
  	    });
  	    discountView_id.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    discountView_id.setBounds(10, 139, 69, 254);
  	    panel_3.add(discountView_id);
  	    
  	    model_discount = new DefaultListModel<String>();
	    for(int i = 0; i > discountList.size(); i++)
	    {
	    	Discount discount = discountList.discounts.get(i);
	    	String temp = (Long.toString(discount.getDiscountId()));
	    	
	    	model.addElement(temp);
	    	
	    	
	    	
	    }
	    discountView_id.setModel(model_discount);
	    
  	    
  	    JLabel lblNameamountdateFromto = new JLabel("Name/Amount/Date from/To");
  	    lblNameamountdateFromto.setBounds(77, 126, 452, 14);
  	    panel_3.add(lblNameamountdateFromto);
  	    
  	    JList<String> discountList_data = new JList<String>();
  	    discountList_data.setEnabled(false);
  	    discountList_data.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    discountList_data.setBounds(78, 139, 489, 254);
  	    panel_3.add(discountList_data);
  	    model_discount_1 = new DefaultListModel<String>();
	    for(int i = 0; i > discountList.size(); i++)
	    {
	    	Discount discount = discountList.discounts.get(i);
	    	String temp = (Long.toString(discount.getDiscountId()));    	
	    	model_discount_1.addElement(temp);  		    	
	    }
	    discountList_data.setModel(model_discount_1);
  	    
  	    
  	    final JPanel panel_4 = new JPanel();
  	    panel_4.setBackground(SystemColor.inactiveCaption);
  	  tabbedPane.addTab("Product View", null, panel_4, null);
  	    
  	    panel_4.setLayout(null);
  	    
  	    JLabel lblProductId = new JLabel("Product ID:");
  	    lblProductId.setBounds(10, 11, 79, 14);
  	    panel_4.add(lblProductId);
  	    
  	    JLabel lblName_2 = new JLabel("Name:");
  	    lblName_2.setBounds(10, 36, 56, 14);
  	    panel_4.add(lblName_2);
  	    
  	    textProductId = new JTextField();
  	    textProductId.setBounds(73, 8, 86, 20);
  	    panel_4.add(textProductId);
  	    textProductId.setColumns(10);
  	    
  	    textProductName = new JTextField();
  	    textProductName.setBounds(73, 33, 86, 20);
  	    panel_4.add(textProductName);
  	    textProductName.setColumns(10);
  	    
  	    JLabel lblInStock = new JLabel("In Stock:");
  	    lblInStock.setBounds(169, 11, 66, 14);
  	    panel_4.add(lblInStock);
  	    
  	    textProductAmount = new JTextField();
  	    textProductAmount.setBounds(219, 8, 86, 20);
  	    panel_4.add(textProductAmount);
  	    textProductAmount.setColumns(10);
  	    
  	    JLabel lblPrice = new JLabel("Price:");
  	    lblPrice.setBounds(169, 36, 46, 14);
  	    panel_4.add(lblPrice);
  	    
  	    textProductPrice = new JTextField();
  	    textProductPrice.setBounds(219, 33, 86, 20);
  	    panel_4.add(textProductPrice);
  	    textProductPrice.setColumns(10);
  	    
  	    JLabel lblDiscount_2 = new JLabel("Discount:");
  	    lblDiscount_2.setBounds(10, 61, 56, 14);
  	    panel_4.add(lblDiscount_2);
  	    
  	    JButton btnSave_2 = new JButton("Create");
  	    btnSave_2.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		int id = Integer.valueOf(textProductId.getText());
  	    		int inStock = Integer.valueOf(textProductAmount.getText());
  	    		double price = Double.valueOf(textProductPrice.getText());
  	    		String productName = textProductName.getText();
  	    		
  	    		productCtr.createProduct(productName, inStock, price, id);
  	    		modelProduct.addElement(Long.toString(id));
  	    		modelProductData.addElement(productName+"/"+price+"/"+inStock);
  	    		textNotification.setText("SYSTEM: Product:"+" "+productName+" "+"with product ID" + id + " " + "was created.");
  	    	}
  	    });
  	    btnSave_2.setBounds(478, 7, 89, 23);
  	    panel_4.add(btnSave_2);
  	    
  	    JButton btnNewButton_1 = new JButton("Edit");
  	    btnNewButton_1.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		//int id = Integer.valueOf(textProductId.getText());
  	    		Integer id = Integer.valueOf(productView_id.getSelectedValue());
  	    		productCtr.setProductName(textProductName.getText(), id);
  	    		productCtr.setAmointInStock(Integer.valueOf(textProductAmount.getText()), id);
  	    		productCtr.setProductPrice(Double.valueOf(textProductPrice.getText()), id);
  	    		textNotification.setText("SYSTEM: Product:"+" "+"with product ID" + id + " " + "was updated.");
  	    	}
  	    });
  	    btnNewButton_1.setBounds(478, 32, 89, 23);
  	    panel_4.add(btnNewButton_1);
  	    
  	    JButton btnDelete_3 = new JButton("Delete");
  	    btnDelete_3.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		Integer id = Integer.valueOf(textProductId.getText());
  	    		productCtr.deleteProduct(id);
  	    		String productName = textProductName.getText();
  	    		textProductAmount.setText(null);
  	    		textProductId.setText(null);
  	    		textProductName.setText(null);
  	    		textProductPrice.setText(null);
  	    		textNotification.setText("SYSTEM: Product:"+" "+productName+" "+"with product ID" + id + " " + "was deleted.");
  	    		int selectedIndex = productView_id.getSelectedIndex();
  	    		if (selectedIndex != -1) {
  	    		    modelProduct.remove(selectedIndex);
  	    		    modelProductData.remove(selectedIndex);
  	    	}
  	    }
  	    });
  	    btnDelete_3.setBounds(478, 57, 89, 23);
  	    panel_4.add(btnDelete_3);
  	    
  	    JLabel lblProductList = new JLabel("Product list:");
  	    lblProductList.setBounds(10, 102, 89, 14);
  	    panel_4.add(lblProductList);
  	    
  	    JLabel label_4 = new JLabel("_______________________________________________________________________________");
  	    label_4.setBounds(10, 112, 557, 14);
  	    panel_4.add(label_4);
  	    
  	    JLabel lblId_2 = new JLabel("ID");
  	    lblId_2.setBounds(10, 127, 46, 14);
  	    panel_4.add(lblId_2);
  	    
  	    productView_id = new JList<String>();
  	    productView_id.addListSelectionListener(new ListSelectionListener() {
  	    	public void valueChanged(ListSelectionEvent e) 
  	    	{
  	    		if (!e.getValueIsAdjusting())
    		    {    
  	    			String str =  productView_id.getSelectedValue();
                 if (str != null || str != "")
                 {
                	 Product product;
                 try{
                 product = productList.findProduct(Integer.valueOf(str));
                 textProductId.setText( productView_id.getSelectedValue());
                 textProductName.setText(product.getProductName());
                 String inStock = Long.toString(product.getInStock());
                 textProductAmount.setText(inStock);
                 String price = Double.toString(product.getPrice());
                 textProductPrice.setText(price);
                 }catch(Exception ex ){textNotification1.setText(ex.getMessage());}
                 
                 
    		    }
              }
  	    	}
  	    });
  	    productView_id.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    productView_id.setBounds(10, 144, 46, 249);
  	    panel_4.add(productView_id);
  	    modelProduct = new DefaultListModel<String>();
	    for(int i = 0; i > productList.size(); i++)
	    {
	    	Product product = productList.products.get(i);
	    	String temp = (Long.toString(product.getId()));    	
	    	modelProduct.addElement(temp);  		    	
	    }
	    productView_id.setModel(modelProduct);
	    
  	    JList<String> productView_data = new JList<String>();
  	    productView_data.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    productView_data.setBounds(55, 144, 512, 249);
  	    panel_4.add(productView_data);
  	    modelProductData = new DefaultListModel<String>();
	    for(int i = 0; i > productList.size(); i++)
	    {
	    	Product product = productList.products.get(i);
	    	String temp = (Long.toString(product.getId()));    	
	    	modelProductData.addElement(temp);  		    	
	    }
	    productView_data.setModel(modelProductData);
  	    
  	    JLabel lblNamepriceinStock = new JLabel("Name/Price/In Stock");
  	    lblNamepriceinStock.setBounds(53, 127, 162, 14);
  	    panel_4.add(lblNamepriceinStock);
  	    modelProductData = new DefaultListModel<String>();
	    for(int i = 0; i > discountList.size(); i++)
	    {
	    	Product product = productList.products.get(i);
	    	String temp = (Long.toString(product.getId()));    	
	    	modelProductData.addElement(temp);  		    	
	    }
	    productView_data.setModel(modelProductData);
	    
	    productDiscountId = new JTextField();
	    productDiscountId.setBounds(73, 58, 86, 20);
	    panel_4.add(productDiscountId);
	    productDiscountId.setColumns(10);
	    
	    JButton btnAdd = new JButton("+");
	    btnAdd.setToolTipText("Add");
	    btnAdd.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent arg0) 
	    	{
	    		Integer id = Integer.valueOf(textProductId.getText());
	    		long discountId = Long.valueOf(productDiscountId.getText());
	    		productCtr.addProductDiscount(id, discountId);
	    		textNotification.setText("SYSTEM: Discount with ID:"+discountId+"were added.");
	    	}
	    });
	    btnAdd.setBounds(159, 57, 41, 23);
	    panel_4.add(btnAdd);
	    
	    
	  // discounts = discountList.discounts.toArray(new Discount[discountList.size()]);
	   //JComboBox<Discount> comboBox = new JComboBox<Discount>(discounts);
	   //comboBox.setBounds(71, 64, 86, 20);
	   //panel_4.add(comboBox);

	   
	    
	    
	    
	    
	    
  	    JPanel panel = new JPanel();
  	    panel.setBackground(SystemColor.inactiveCaption);
  	    tabbedPane.addTab("User View", null, panel, null);
  	    panel.setLayout(null);
  	    
  	    JLabel lblUserId = new JLabel("User ID:");
  	    lblUserId.setBounds(10, 11, 66, 14);
  	    panel.add(lblUserId);
  	    
  	    JLabel lblName_3 = new JLabel("Name:");
  	    lblName_3.setBounds(10, 36, 46, 14);
  	    panel.add(lblName_3);
  	    
  	    JLabel lblSurname_1 = new JLabel("Surname:");
  	    lblSurname_1.setBounds(10, 61, 66, 14);
  	    panel.add(lblSurname_1);
  	    
  	    textFieldUserId = new JTextField();
  	    textFieldUserId.setBounds(76, 8, 86, 20);
  	    panel.add(textFieldUserId);
  	    textFieldUserId.setColumns(10);
  	    
  	    textFieldUserName = new JTextField();
  	    textFieldUserName.setBounds(76, 33, 86, 20);
  	    panel.add(textFieldUserName);
  	    textFieldUserName.setColumns(10);
  	    
  	    textFieldUserSurname = new JTextField();
  	    textFieldUserSurname.setBounds(76, 58, 86, 20);
  	    panel.add(textFieldUserSurname);
  	    textFieldUserSurname.setColumns(10);
  	    
  	    JLabel lblEmail_1 = new JLabel("Email:");
  	    lblEmail_1.setBounds(172, 11, 46, 14);
  	    panel.add(lblEmail_1);
  	    
  	    JLabel lblUserRole = new JLabel("User Role:");
  	    lblUserRole.setBounds(172, 36, 66, 14);
  	    panel.add(lblUserRole);
  	    
  	    JLabel lblPhone_1 = new JLabel("Phone:");
  	    lblPhone_1.setBounds(172, 61, 66, 14);
  	    panel.add(lblPhone_1);
  	    
  	    textFieldUserEmail = new JTextField();
  	    textFieldUserEmail.setBounds(238, 8, 86, 20);
  	    panel.add(textFieldUserEmail);
  	    textFieldUserEmail.setColumns(10);
  	    
  	    textUserRole = new JTextField();
  	    textUserRole.setBounds(238, 33, 86, 20);
  	    panel.add(textUserRole);
  	    textUserRole.setColumns(10);
  	    
  	    textFieldUserPhone = new JTextField();
  	    textFieldUserPhone.setBounds(238, 58, 86, 20);
  	    panel.add(textFieldUserPhone);
  	    textFieldUserPhone.setColumns(10);
  	    
  	    JLabel lblPassword = new JLabel("Password:");
  	    lblPassword.setBounds(10, 86, 66, 14);
  	    panel.add(lblPassword);
  	    
  	    passwordField = new JPasswordField();
  	    passwordField.setBounds(76, 83, 86, 20);
  	    panel.add(passwordField);
  	    
  	    JButton btnCreate = new JButton("Create");
  	    btnCreate.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent arg0) 
  	    	{
  	    		long userId = Long.valueOf(textFieldUserId.getText());
  	    		String name = textFieldUserName.getText();
  	    		String surname = textFieldUserSurname.getText();
  	    		String password = passwordField.getText();
  	    		String email = textFieldUserEmail.getText();
  	    		String role = textUserRole.getText();
  	    		String phoneNumber = textFieldUserPhone.getText();
  	    		employeeCtr.createEmployee(userId, name, surname, password, email, role, phoneNumber);
  	    		modelUserId.addElement(Long.toString(userId));
  	    		modelUserData.addElement(name+" "+surname+"/"+role+"/"+email);
  	    		textNotification.setText("SYSTEM: Employee:"+" "+name+" "+surname+" "+"with  ID" + userId + " " + "was created.");
  	    	}
  	    });
  	    btnCreate.setBounds(478, 7, 89, 23);
  	    panel.add(btnCreate);
  	    
  	    JButton btnSave_3 = new JButton("Edit");
  	    btnSave_3.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long userId = Long.valueOf(textFieldUserId.getText());
  	    		employeeCtr.setEmployeeName(textFieldUserName.getText(), userId);
  	    		employeeCtr.setEmployeeEmail(textFieldUserEmail.getText(), userId);
  	    		employeeCtr.setEmployeePassword(passwordField.getText(), userId);
  	    		employeeCtr.setEmployeePhoneNumber(textFieldUserPhone.getText(), userId);
  	    		employeeCtr.setEmployeeRole(textUserRole.getText(), userId);
  	    		employeeCtr.setEmployeeSurname(textFieldUserSurname.getText(), userId);  	    		
  	    		textNotification.setText("SYSTEM: User:"+" "+"with ID" + userId + " " + "was updated.");
  	    	}
  	    });
  	    btnSave_3.setBounds(478, 32, 89, 23);
  	    panel.add(btnSave_3);
  	    
  	    JButton btnDelete_4 = new JButton("Delete");
  	    btnDelete_4.addActionListener(new ActionListener() {
  	    	public void actionPerformed(ActionEvent e) 
  	    	{
  	    		long userId = Long.valueOf(textFieldUserId.getText());
  	    		employeeCtr.deleteEmployee(userId);
  	    		String name = textFieldUserName.getText();
  	    		String surname = textFieldUserSurname.getText();
  	    		textFieldUserId.setText(null);
  	    		textFieldUserEmail.setText(null);
  	    		textFieldUserName.setText(null);
  	    		textFieldUserPhone.setText(null);
  	    		textFieldUserSurname.setText(null);
  	    		textUserRole.setText(null);
  	    		passwordField.setText(null); 		   
  	    		  textNotification.setText("SYSTEM: User:"+" "+name+" "+surname+"with ID" + userId + " " + "was deleted.");
  	    		int selectedIndex = listUserId.getSelectedIndex();
  	    		if (selectedIndex != -1) {
  	    		    modelUserId.remove(selectedIndex);
  	    		    modelUserData.remove(selectedIndex);
  	    	}
  	    	}
  	    		
  	    });
  	    btnDelete_4.setBounds(478, 57, 89, 23);
  	    panel.add(btnDelete_4);
  	    
  	    JLabel lblUserList = new JLabel("User list:");
  	    lblUserList.setBounds(10, 111, 66, 14);
  	    panel.add(lblUserList);
  	    
  	    JLabel label_5 = new JLabel("_______________________________________________________________________________");
  	    label_5.setBounds(10, 123, 557, 14);
  	    panel.add(label_5);
  	    
  	    JLabel lblId_3 = new JLabel("ID");
  	    lblId_3.setBounds(10, 136, 46, 14);
  	    panel.add(lblId_3);
  	    
  	    listUserId = new JList<String>();
  	    listUserId.addListSelectionListener(new ListSelectionListener() {
  	    	public void valueChanged(ListSelectionEvent e) 
  	    	{
  	    		if (!e.getValueIsAdjusting())
    		    {    
  	    			String str =  listUserId.getSelectedValue();
                 if (str != null || str != "")
                 {
                	 Employee employee;
                 try{
                 employee = employeeList.findEmployee(Long.valueOf(str));
                 textFieldUserId.setText( listUserId.getSelectedValue());
                 textFieldUserName.setText(employee.getName());
                 textFieldUserSurname.setText(employee.getSurname());
                 textFieldUserEmail.setText(employee.getEmail());
                 textUserRole.setText(employee.getRole());
                 textFieldUserPhone.setText(employee.getPhoneNumber());
                 passwordField.setText(employee.getPassword());
                 }catch(Exception ex ){textNotification1.setText(ex.getMessage());}
  	    		
  	    	}
    	  }
        }
  	    });
  	    modelUserId = new DefaultListModel<String>();
	    for(int i = 0; i > employeeList.size(); i++)
	    {
	    	Employee employee = employeeList.employees.get(i);
	    	String temp = (Long.toString(employee.getEmployeeId()));    	
	    	modelUserId.addElement(temp);  		    	
	    }
	    listUserId.setModel(modelUserId);
  	    listUserId.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    listUserId.setBounds(10, 150, 66, 243);
  	    panel.add(listUserId);
  	    
  	    JLabel lblNamesurnameuserRoleEmail = new JLabel("Name/Surname/User Role/ Email");
  	    lblNamesurnameuserRoleEmail.setBounds(76, 136, 403, 14);
  	    panel.add(lblNamesurnameuserRoleEmail);
  	    
  	    JList<String> listUserData = new JList<String>();
  	    listUserData.setBorder(new LineBorder(new Color(0, 0, 0)));
  	    listUserData.setBounds(75, 150, 492, 243);
  	    panel.add(listUserData);
  	    modelUserData = new DefaultListModel<String>();
	    for(int i = 0; i > employeeList.size(); i++)
	    {
	    	Employee employee = employeeList.employees.get(i);
	    	String temp = (Long.toString(employee.getEmployeeId()));    	
	    	modelUserId.addElement(temp); 
	    }
	    listUserData.setModel(modelUserData);
  	    
  	    JLabel lblOrderList = new JLabel("Order list:");
  	    lblOrderList.setBounds(10, 49, 90, 14);
  	    contentPane.add(lblOrderList);
  	    // panel_2.setVisible();
    
  	  JMenuBar menuBar = new JMenuBar();
  	  menuBar.setBackground(SystemColor.inactiveCaption);
		menuBar.setBounds(0, 0, 800, 21);
		contentPane.add(menuBar);
		JMenu mnOrder = new JMenu("System");
      menuBar.add(mnOrder);
      JMenuItem orderView = new JMenuItem("Quit");
	    mnOrder.add(orderView);
      JMenu mnCustomer = new JMenu("Customer");
      menuBar.add(mnCustomer);
	    JMenuItem customerView = new JMenuItem("Customer View");
	    customerView.addMouseListener(new MouseAdapter() {
	    	@Override
	    	public void mousePressed(MouseEvent e) {
	    		  tabbedPane.addTab("Customer View", null, panel_2, null);
	    		 
	    	}
	    });
	   
	    mnCustomer.add(customerView);
	    JMenuItem mnDiscounts = new JMenu("Discounts");
	    menuBar.add(mnDiscounts);
	    JMenuItem discountsView = new JMenuItem("Discount View");
	    discountsView.addMouseListener(new MouseAdapter() {
	    	@Override
	    	public void mousePressed(MouseEvent e) 
	    	{
	    		tabbedPane.addTab("Discount View", null, panel_3, null);
	    		
	    	}
	    });
	    mnDiscounts.add(discountsView);
	    JMenu mnProducts= new JMenu("Products");
	    menuBar.add(mnProducts);
	    JMenuItem porductView = new JMenuItem("Product View");
	    porductView.addMouseListener(new MouseAdapter() {
	    	@Override
	    	public void mousePressed(MouseEvent e)
	    	{
	    		tabbedPane.addTab("Product View", null, panel_4, null);
	    	}
	    	
		    
	    });
	    JMenu mnOrder1 = new JMenu("Users");
	      menuBar.add(mnOrder1);
	      JMenuItem orderView1 = new JMenuItem("User View");
		    mnOrder1.add(orderView1);
	    
	    
	    
	    mnProducts.add(porductView);
	    
	    JLabel lblLogitechVBeta = new JLabel("Logitech. v1.02 Beta");
	    lblLogitechVBeta.setFont(new Font("Segoe UI Symbol", Font.PLAIN, 14));
	    lblLogitechVBeta.setBounds(10, 478, 178, 32);
	    contentPane.add(lblLogitechVBeta);
	    
	    final JList<String> list = new JList<String>();
	    list.addListSelectionListener(new ListSelectionListener() {
	    	public void valueChanged(ListSelectionEvent e) 
	    	{
	    		  if (!e.getValueIsAdjusting())
	    		    {    
	    			  	
	                   String str =  list.getSelectedValue().toString();
	                   
	                   Order order = orderList.findOrder(Long.valueOf(str));
	                   
	                   String orderIdtext = Long.toString(order.getOrderId());
	                   orderId_text.setText(orderIdtext);
	                   textField_2.setText(order.getOrderDate());
	                   txtfield.setText(order.getDeliveryDate());
	                   textField_4.setText(order.getStatus());
	                   
	    			   
	                   
	                   
	                }
	    	}
	    });
	    list.setBorder(new LineBorder(new Color(0, 0, 0)));
	    list.setBounds(10, 68, 178, 407);
	    contentPane.add(list);
	  
	    
	    
	    
	   
	    
	    
	    model = new DefaultListModel<String>();
	    for(int i = 0; i > orderList.size(); i++)
	    {
	    	Order order = orderList.orders.get(i);
	    	String temp = (Long.toString(order.getOrderId())+"/"+ order.getOrderDate());
	    	
	    	model.addElement("ID:" +temp);

	    }
	    list.setModel(model);
	    
	    textNotification1 = new JTextField();
	    textNotification1.setEnabled(false);
	    textNotification1.setEditable(false);
	    textNotification1.setBounds(694, 486, 86, 20);
	    contentPane.add(textNotification1);
	    textNotification1.setColumns(10);

	
	}

	private JMenu makeMenuItem(String string) {
		// TODO Auto-generated method stub
		return null;
	}
	public class DropDownItem
	{
		int id;
		String name;
		public DropDownItem(int id, String name)
		{
			this.id = id;
			this.name = name;
		}
		public String toString()
		{
			return this.name;
		}
		public int getId()
		{
			return this.id;
		}
	}
}

